package com.bins.dentist.clinic.model.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResultVo<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	private int code;

	private String msg;

	private T data;

	public static ResultVo ok() {
		return ResultVo.builder().code(0).build();
	}

	public static ResultVo fail(String msg) {
		return ResultVo.builder().code(1000).msg(msg).build();
	}

	public ResultVo data(T data) {
		this.data = data;
		return this;
	}

	public ResultVo code(int code) {
		this.code = code;
		return this;
	}

	public ResultVo msg(String msg) {
		this.msg = msg;
		return this;
	}

}
